<template>
  <!--属性定义-->
  <basic-container>
    <div>
      <m-s-search @searchClick="v=>{queryForm=v,page.currentPage=1,getList()}" :list="PropertiesDefinedOption.column"></m-s-search>
    </div>
    <avue-crud :option="PropertiesDefinedOption"
               :table-loading="loading"
               :data="data"
               @current-change="currentChange"
               @size-change="sizeChange"
               @selection-change="v=>selection=v"
               ref="crud"
               :page.sync="page">
      <template slot="menuLeft" slot-scope="{size}">
        <el-button :size="size" type="primary"
                   @click="addToTabsList('属性',{oid:-1},'PropertiesDefinedTemp','open')">创建
        </el-button>
        <el-button :size="size" type="danger" :disabled="selection.length===0"
                   @click="remove(selection)">删除
        </el-button>
        <el-button :disabled="selection.length===0" :size="size"
                   @click="start_stop(selection,'start')">启用
        </el-button>
        <el-button :disabled="selection.length===0" :size="size"
                   @click="start_stop(selection,'stop')">停用
        </el-button>
      </template>

      <template slot="nameCn" slot-scope="{row}">
        <span class="column-btn" @click="addToTabsList(row.nameCn+'属性',row,'PropertiesDefinedTemp','view')">
          {{ row.nameCn }}
        </span>
      </template>

      <template slot="menu" slot-scope="{row}">
        <el-button type="text" @click="addToTabsList(row.nameCn+'属性',row,'PropertiesDefinedTemp','view')">
          查看详情
        </el-button>
        <el-button type="text" @click="addToTabsList(row.nameCn+'属性',row,'PropertiesDefinedTemp','edit')">
          修改
        </el-button>
        <el-button type="text" :disabled="row.state===0" @click="start_stop([row],'stop')">停用</el-button>
      </template>
    </avue-crud>

    <ms-drawer @refresh="getList()" :visible.sync="visible" :tab-list.sync="tabsList"></ms-drawer>
  </basic-container>
</template>

<script>
import MSSearch from "@/DMDComponents/MSSearch.vue";
import commonJs from "@/util/commonJs";
import * as common from "@/api/common";
import {request} from "axios";

export default {
  name: "PropertiesDefined",
  components: {MSSearch},
  inject: ["PropertiesDefinedOption"],
  mixins: [commonJs]
}
</script>
